
const User = {
    state: {
        // 用户id
        userId: "",
        // 用户头像
        userPic: "",
        // 用户昵称
        nickName: "用户",
        // 用户创建的组和加入的组
        groupId: [],
        // 创建新群聊时, 各成员接受一个参数渲染一个群组在 "homeView' 页面,
        createGroupAcceptNews: {
        }
    },
    mutations: {
        setAppUserIdM(state, id) {
            state.userId = id
        },
        setUserInfo(state, obj) {
            state.userId = obj.phone
            state.userPic = obj.avatarurl
            state.nickName = obj.nickname
        },
        setGroupId(state, str) {
            let flag = false
            state.groupId.map(item => {
                if (item == str) {
                    flag = true
                }
            })
            if (!flag) {
                state.groupId.push(str)
            }
        },
        setCreateGroupAcceptNews(state, obj) {
            state.createGroupAcceptNews=obj
            //  newGroupId: 群组id,
            // newGroupOwner: 群主
        }
    },
    actions: {
        setAppUserIdA(context, payload) {
            context.commite("setAppUserIdM", payload)
        },
        setAppUserInfo(context, payload) {
            context.commite("setUserInfo", payload)
        }
    }
}
export default User;